package de.slothsoft.wasbinich.android;

import static de.slothsoft.wasbinich.android.preference.PreferenceConstants.PREF_LANGUAGE;
import static de.slothsoft.wasbinich.android.preference.PreferenceConstants.PREF_MUSIC;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.View;
import de.slothsoft.wasbinich.android.preference.PreferenceUtil;
import de.slothsoft.wasbinich.android.util.ActivityUtil;
import de.slothsoft.wasbinich.android.util.SvgUtil;

/**
 * A {@link PreferenceActivity} that presents a set of application settings. On
 * handset devices, settings are presented as a single list. On tablets,
 * settings are split by category, with category headers shown to the left of
 * the list of settings.
 * <p>
 * See <a href="http://developer.android.com/design/patterns/settings.html">
 * Android Design: Settings</a> for design guidelines and the <a
 * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
 * API Guide</a> for more information on developing a Settings UI.
 */

public class SettingsActivity extends PreferenceActivity {

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
	super.onPostCreate(savedInstanceState);
	setupSimplePreferencesScreen();
    }

    /**
     * Shows the simplified settings UI if the device configuration if the
     * device configuration dictates that a simplified, single-pane UI should be
     * shown.
     */

    private void setupSimplePreferencesScreen() {
	addPreferencesFromResource(R.xml.pref_general);
	PreferenceUtil.bindPreferenceToLocale(this, findPreference(PREF_LANGUAGE));
	PreferenceUtil.bindPreferenceToMusic(this, findPreference(PREF_MUSIC));
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
	super.onWindowFocusChanged(hasFocus);
	View view = getWindow().getDecorView();
	SvgUtil.setSvgToBackground(this, view, R.raw.background);
	ActivityUtil.setCurrentActivity(this);
    }

}
